package com.morningyet.bug.log4j2.application;

import com.morningyet.bug.log4j2.application.controller.UserController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 被攻击应用
 * @author moringyet
 */
@SpringBootApplication

public class BugLog4j2Application implements InitializingBean {

    private static final Logger logger = LoggerFactory.getLogger(UserController.class);

    public static void main(String[] args) {

        logger.info("======================================");

        logger.info("java.version:{}", System.getProperty("java.version"));
        logger.info("java.version:{}", System.getProperty("os.name"));
        logger.info("java.version:{}", System.getProperty("user.home"));
        logger.info("java.version:{}", System.getProperty("java.vendor.url"));

        logger.info("======================================");

        SpringApplication.run(BugLog4j2Application.class, args);
    }

    /**
     * 开启远程加载字节码配置, 仅仅用于问题演示
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase", "true");
        System.setProperty("com.sun.jndi.ldap.object.trustURLCodebase", "true");
    }

}
